//
//$Id: utils.h 722 2012-11-29 17:33:43Z andrew.tsyganov $
#pragma once

#include "subset.h"
#include "types.h"

inline std::string IntToString(size_t val)
{
    char buff[32];
    sprintf(buff, "%u", val);

    return std::string(buff);
}

inline size_t Width(size_t const val)
{
    size_t w = 0;
    for (size_t n = val; n > 0; n /= 10)
    {
        ++w;
    }

    return w;
}

inline std::string IntToStringZ(size_t const val, size_t const max)
{
    char buff[32];
    sprintf(buff, "%0*u", Width(max), val);

    return std::string(buff);
}

inline double log2(double x)
{
    return log(x)/log(2.0);
}

inline void PrintLine(std::ostream& os, size_t const width, char const sym = '-')
{
    for (size_t i = 0; i < width; ++i)
        os << sym; 
    os << std::endl;
}

std::string OpenBracket(Brackets_Type const bt);
std::string CloseBracket(Brackets_Type const bt);

std::string GetFileExtension(std::string const& filename);
std::string CreatePath(std::string const& dir, std::string const& file);
void SplitFilename(std::string const& path, std::string& dir, std::string& file);
void SplitFilename(std::string const& path, std::string& dir, std::string& name, std::string& ext);

size_t Min(size_t a, size_t b, size_t c);

bool EquivalentRows(Bool_Matrix const& m, size_t const i, size_t const j); 
bool EquivalentColumns(Bool_Matrix const& m, size_t const i, size_t const j); 
bool AllOnesInRow(Bool_Matrix const& m, size_t const i, Subset const& s);
bool AllOnesInColumn(Bool_Matrix const& m, size_t const j, Subset const& s);
size_t OnesCount(Bool_Matrix const& m);

//EOF!
